import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '宏城物业信息数字化', icon: 'dashboard' }
    }]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: '公司管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: '基本信息', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: '组织架构', icon: 'tree' },
        children:[
          {
            path:'department',
            name:'Dpartment',
            component:()=>import('@/views/tree/department'),
            meta:{title:'部门信息'}
          },
          {
            path:'personnel',
            name:'Personnel',
            component:()=>import('@/views/tree/personnel'),
            meta:{title:'人员管理'}
          }
        ]
      },
      {
        path: 'right',
        name: 'Right',
        component: () => import('@/views/right/index'),
        meta: { title: '权限管理', icon: 'tree' }
      }
    ]
  },



  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '项目管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '基本信息' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: '基本信息1' }
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: '基本信息2' }
          }
        ]
      },


      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'), // Parent router-view
        name: 'Menu2',
        meta: { title: '楼栋信息' },
        // children: [
        //   {
        //     path: 'menu2-1',
        //     component: () => import('@/views/nested/menu2/menu2-1'),
        //     name: 'Menu2-1',
        //     meta: { title: '业主列表' }
        //   },
        //   {
        //     path: 'menu2-2',
        //     component: () => import('@/views/nested/menu2/menu2-2'),
        //     name: 'Menu2-2',
        //     meta: { title: '变更信息' }
        //   }
        // ]
      },
      {
        path: 'menu3',
        component: () => import('@/views/nested/menu4/index'), // Parent router-view
        name: 'Menu3',
        meta: { title: '设备信息' },
        // children: [
        //   {
        //     path: 'menu3-1',
        //     component: () => import('@/views/nested/menu3/menu3-1'),
        //     name: 'Menu3-1',
        //     meta: { title: '表卡信息' }
        //   },
        // ]
      },
      {
        path: 'menu4',
        component: () => import('@/views/nested/menu4/index'), // Parent router-view
        name: 'Menu4',
        meta: { title: '设施信息' },
        // children: [
        //   {
        //     path: 'menu4-1',
        //     component: () => import('@/views/nested/menu4/menu4-1'),
        //     name: 'Menu4-1',
        //     meta: { title: '物业缴费统计' }
        //   },
        //   {
        //     path: 'menu4-2',
        //     component: () => import('@/views/nested/menu4/menu4-2'),
        //     name: 'Menu4-2',
        //     meta: { title: '账单缴费分析' }
        //   },
        //   {
        //     path: 'menu4-3',
        //     component: () => import('@/views/nested/menu4/menu4-3'),
        //     name: 'Menu4-3',
        //     meta: { title: '房产收费项目' }
        //   },
        //   {
        //     path: 'menu4-4',
        //     component: () => import('@/views/nested/menu4/menu4-4'),
        //     name: 'Menu4-4',
        //     meta: { title: '生成账单' }
        //   },
        //   {
        //     path: 'menu4-5',
        //     component: () => import('@/views/nested/menu4/menu4-5'),
        //     name: 'Menu4-5',
        //     meta: { title: '账单催交' }
        //   },
        //   {
        //     path: 'menu4-6',
        //     component: () => import('@/views/nested/menu4/menu4-6'),
        //     name: 'Menu4-6',
        //     meta: { title: '收费项目' }
        //   },
        //   {
        //     path: 'menu4-7',
        //     component: () => import('@/views/nested/menu4/menu4-7'),
        //     name: 'Menu4-7',
        //     meta: { title: '物业账单' }
        //   },
        //   {
        //     path: 'menu4-8',
        //     component: () => import('@/views/nested/menu4/menu4-8'),
        //     name: 'Menu4-8',
        //     meta: { title: '抄表账单' }
        //   },
        //   {
        //     path: 'menu4-9',
        //     component: () => import('@/views/nested/menu4/menu4-9'),
        //     name: 'Menu4-9',
        //     meta: { title: '已交账单' }
        //   },
        //   {
        //     path: 'menu4-10',
        //     component: () => import('@/views/nested/menu4/menu4-10'),
        //     name: 'Menu4-10',
        //     meta: { title: '核对账单' }
        //   },
        //   {
        //     path: 'menu4-11',
        //     component: () => import('@/views/nested/menu4/menu4-11'),
        //     name: 'Menu4-11',
        //     meta: { title: '收支登记' }
        //   },
        //   {
        //     path: 'menu4-12',
        //     component: () => import('@/views/nested/menu4/menu4-12'),
        //     name: 'Menu4-12',
        //     meta: { title: '预处理账单' }
        //   },
        // ]
      },
      {
        path: 'menu5',
        component: () => import('@/views/nested/menu5/index'), // Parent router-view
        name: 'Menu5',
        meta: { title: '收费信息' },
        children: [
          {
            path: 'menu5-1',
            component: () => import('@/views/nested/menu5/menu5-1'),
            name: 'Menu5-1',
            meta: { title: '交付阶段' }
          },
          {
            path: 'menu5-2',
            component: () => import('@/views/nested/menu5/menu5-2'),
            name: 'Menu5-2',
            meta: { title: '交费阶段' }
          },
        ]
      },
    ]
  },

  {
    path: '/basic-services',
    component: Layout,
    redirect: '/basic-services/demo1',
    name: 'basic-services',
    meta: { title: '企业信息', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'demo1',
        name: 'Demo1',
        component: () => import('@/views/basic-services/demo1/index'),
        meta: { title: '企业信息', icon: 'table' }
      },
    //   {
    //     path: 'demo2',
    //     name: 'Demo2',
    //     component: () => import('@/views/basic-services/demo2/index'),
    //     meta: { title: '模块2', icon: 'tree' }
    //   },
    //   {
    //     path: 'demo3',
    //     name: 'Demo3',
    //     component: () => import('@/views/basic-services/demo3/index'),
    //     meta: { title: '模块1', icon: 'tree' },
    //     children: [
    //       {
    //         path: 'demo3-1',
    //         component: () => import('@/views/basic-services/demo3/demo3-1'),
    //         name: 'Demo3-1',
    //         meta: { title: '通知模块' },
    //       },
    //       {
    //         path: 'demo3-2',
    //         component: () => import('@/views/basic-services/demo3/demo3-2'),
    //         name: 'demo3-2',
    //         meta: { title: '业主报修' },
    //       },
    //       {
    //         path: 'demo3-3',
    //         component: () => import('@/views/basic-services/demo3/demo3-3'),
    //         name: 'demo3-3',
    //         meta: { title: '图文发布' },
    //       },
    //     ]
    //   },
    //   {
    //     path: 'demo4',
    //     name: 'Demo4',
    //     component: () => import('@/views/basic-services/demo4/index'),
    //     meta: { title: '房屋租赁', icon: 'tree' }
    //   },
    //   {
    //     path: 'demo5',
    //     name: 'Demo5',
    //     component: () => import('@/views/basic-services/demo5/index'),
    //     meta: { title: '报修服务', icon: 'tree' }
    //   },
    ]
  },

  {
    path: '/hardware',
    component: Layout,
    redirect: '/hardware/demo1',
    name: 'Hardware',
    meta: { title: '社区硬件', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'demo1',
        name: 'demo1',
        component: () => import('@/views/hardware/demo1/index'),
        meta: { title: '小区监控', icon: 'table' }
      },
      {
        path: 'demo2',
        name: 'demo2',
        component: () => import('@/views/hardware/demo2/index'),
        meta: { title: '小区充电桩', icon: 'tree' }
      },
      {
        path: 'demo3',
        name: 'demo3',
        component: () => import('@/views/hardware/demo3/index'),
        meta: { title: '智慧停车', icon: 'table' }
      },
      {
        path: 'demo4',
        name: 'demo4',
        component: () => import('@/views/hardware/demo4/index'),
        meta: { title: '蓝牙门禁', icon: 'tree' }
      },
      {
        path: 'demo5',
        name: 'demo5',
        component: () => import('@/views/hardware/demo5/index'),
        meta: { title: '人脸录入信息', icon: 'table' }
      },
      {
        path: 'demo6',
        name: 'demo6',
        component: () => import('@/views/hardware/demo6/index'),
        meta: { title: '智能快递', icon: 'table' }
      },
      {
        path: 'demo7',
        name: 'demo7',
        component: () => import('@/views/hardware/demo7/index'),
        meta: { title: '外卖柜', icon: 'table' }
      }
    ]
  },

  {
    path: '/multiterminal',
    component: Layout,
    redirect: '/multiterminal/demo1',
    name: 'multiterminal',
    meta: { title: '多端使用', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'demo1',
        component: () => import('@/views/multiterminal/demo1'),
        meta: { title: '微信公众号', icon: 'table' },
        children: [
          {
            path: 'demo1-1',
            component: () => import('@/views/multiterminal/demo1/demo1-1'),
            name: 'Demo1-1',
            meta: { title: '公众号绑定' },
          },
          {
            path: 'demo1-2',
            component: () => import('@/views/multiterminal/demo1/demo1-2'),
            name: 'Demo1-2',
            meta: { title: '模板消息' },
          },
          {
            path: 'demo1-3',
            component: () => import('@/views/multiterminal/demo1/demo1-3'),
            name: 'Demo1-3',
            meta: { title: '自动回复' },
          },
          {
            path: 'demo1-4',
            component: () => import('@/views/multiterminal/demo1/demo1-4'),
            name: 'Demo1-4',
            meta: { title: '自定义菜单' },
          },
          {
            path: 'demo1-5',
            component: () => import('@/views/multiterminal/demo1/demo1-5'),
            name: 'Demo1-5',
            meta: { title: '关键字回复' },
          },
          {
            path: 'demo1-6',
            component: () => import('@/views/multiterminal/demo1/demo1-6'),
            name: 'Demo1-6',
            meta: { title: '图文素材' },
          },
        ]
      },
      {
        path: 'demo2',
        component: () => import('@/views//multiterminal/demo2'),
        meta: { title: '微信小程序', icon: 'tree' },
        children: [
          {
            path: 'demo2-1',
            component: () => import('@/views/multiterminal/demo2/demo2-1'),
            name: 'Demo2-1',
            meta: { title: '业主端' },
          },
          {
            path: 'demo2-2',
            component: () => import('@/views/multiterminal/demo2/demo2-2'),
            name: 'Demo2-2',
            meta: { title: '物主端' },
          }
        ]
      },
      {
        path: 'demo3',
        component: () => import('@/views/multiterminal/demo3'),
        name: 'Demo3',
        meta: { title: '企业微信', icon: 'tree'  },
      },
    ]
  },

  // {
  //   path: '/appreciation',
  //   component: Layout,
  //   redirect: '/appreciation/demo1',
  //   name: 'appreciation',
  //   meta: { title: '增值服务', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'demo1',
  //       component: () => import('@/views/appreciation/demo1'),
  //       meta: { title: '家政服务', icon: 'table' }
  //     },
  //     {
  //       path: 'demo2',
  //       component: () => import('@/views/appreciation/demo2'),
  //       meta: { title: '陪护服务', icon: 'table' }
  //     },
  //     {
  //       path: 'demo3',
  //       component: () => import('@/views/appreciation/demo3'),
  //       meta: { title: '照料服务', icon: 'table' }
  //     }
  //   ]
  // },


  {
    path: '/system',
    component: Layout,
    redirect: '/system/demo1',
    name: 'system',
    meta: { title: '运行维护', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'demo1',
        component: () => import('@/views/system/demo1'),
        meta: { title: '交付管理', icon: 'table' },
        children:[
          {
            path:'demo1-1',
            component:()=>import('@/views/system/demo1/demo1-1'),
            meta: { title: '收费', icon: 'table' },
          },
          {
            path:'demo1-2',
            component:()=>import('@/views/system/demo1/demo1-2'),
            meta: { title: '流程', icon: 'table' },
          },
          {
            path:'demo1-3',
            component:()=>import('@/views/system/demo1/demo1-3'),
            meta: { title: '权限', icon: 'table' },
          },
          {
            path:'demo1-4',
            component:()=>import('@/views/system/demo1/demo1-4'),
            meta: { title: '终端', icon: 'table' },
          },

        ]
      },
      {
        path: 'demo2',
        component: () => import('@/views/system/demo2'),
        meta: { title: '停车管理', icon: 'table' }
      },
      {
        path: 'demo3',
        component: () => import('@/views/system/demo3'),
        meta: { title: '设备管理', icon: 'table' }
      },
      {
        path: 'demo4',
        component: () => import('@/views/system/demo3'),
        meta: { title: '设施管理', icon: 'table' }
      },
    ]
  },

 

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
